home *** CD-ROM | disk | FTP | other *** search
Wrap
property appearWhen, softWipeDuration, direction, softWipeWidth, spriteNum, mySprite, myStartFrame, myEndFrame, myOriginalMember, myOriginalImage, myOriginalAlpha, myTransitionMember, mySoftEdge, myTransitionMask, myAlphaMask on beginSprite me mySprite = sprite(spriteNum) myOriginalMember = mySprite.member myOriginalAlpha = image(myOriginalMember.width, myOriginalMember.height, 8, #grayscale) myOriginalAlpha.fill(0, 0, myOriginalMember.width, myOriginalMember.height, rgb(0, 0, 0)) myOriginalImage = image(myOriginalMember.width, myOriginalMember.height, 32) case myOriginalMember.type of #bitmap: myOriginalImage = myOriginalMember.image case myOriginalMember.depth of 32: if myOriginalMember.useAlpha then myOriginalAlpha = myOriginalMember.image.extractAlpha() end if end case #text, #vectorShape, #flash: if myOriginalMember.type = #text then mySprite.rect = mySprite.rect end if myOriginalAlpha = myOriginalMember.image.extractAlpha() if mySprite.ink = 0 then case myOriginalMember.type of #text, #flash: myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.bgColor) #vectorShape: myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.backgroundColor) end case myOriginalImage.copyPixels(myOriginalMember.image, myOriginalMember.rect, myOriginalImage.rect, [#maskImage: myOriginalAlpha]) myOriginalAlpha.fill(myOriginalAlpha.rect, rgb(0, 0, 0)) else myOriginalImage = myOriginalMember.image end if end case myAlphaMask = image(myOriginalMember.width, myOriginalMember.height, 8, 0, #grayscale) myAlphaMask.fill(0, 0, myOriginalMember.width, myOriginalMember.height, rgb(255, 255, 255)) case appearWhen of "beginning of sprite": myStartFrame = mySprite.startFrame myEndFrame = myStartFrame + softWipeDuration - 1 "end of sprite": myEndFrame = mySprite.endFrame myStartFrame = myEndFrame - softWipeDuration + 1 end case myTransitionMember = new(#bitmap, castLib(mySprite.castLibNum)) myTransitionMember.image = image(myOriginalMember.width, myOriginalMember.height, 32, 8) myTransitionMember.image.copyPixels(myOriginalImage, myOriginalMember.rect, myOriginalMember.rect) myTransitionMember.regPoint = myOriginalMember.regPoint myTransitionMember.useAlpha = 1 mySoftEdge = softWipeWidth case direction of "left to right", "right to left": myTransitionMask = me.makeSharpBoxLR((myTransitionMember.width * 2) + mySoftEdge, myTransitionMember.height) myTransitionMask.copyPixels(me.makeBlendBoxLR(mySoftEdge, myTransitionMember.height), rect(myTransitionMember.width, 0, myTransitionMember.width + mySoftEdge, myTransitionMember.height), rect(0, 0, mySoftEdge, myTransitionMember.height)) if ((appearWhen = "beginning of sprite") and (direction = "right to left")) or ((appearWhen = "end of sprite") and (direction = "left to right")) then myTransitionMask.copyPixels(myTransitionMask, [point(myTransitionMask.width, 0), point(0, 0), point(0, myTransitionMask.height), point(myTransitionMask.width, myTransitionMask.height)], myTransitionMask.rect) end if "top to bottom", "bottom to top": myTransitionMask = me.makeSharpBoxTB(myTransitionMember.width, (myTransitionMember.height * 2) + mySoftEdge) myTransitionMask.copyPixels(me.makeBlendBoxLR(mySoftEdge, myTransitionMember.width), [point(0, myTransitionMember.height + mySoftEdge), point(0, myTransitionMember.height), point(myTransitionMember.width, myTransitionMember.height), point(myTransitionMember.width, myTransitionMember.height + mySoftEdge)], rect(0, 0, mySoftEdge, myTransitionMember.width)) if ((appearWhen = "end of sprite") and (direction = "bottom to top")) or ((appearWhen = "beginning of sprite") and (direction = "top to bottom")) then myTempAlpha = image(myTransitionMember.width, (myTransitionMember.height * 2) + mySoftEdge, 8, 0, #grayscale) myTempAlpha = duplicate(myTransitionMask) myTransitionMask.copyPixels(myTempAlpha, [point(myTransitionMask.width, myTransitionMask.height), point(0, myTransitionMask.height), point(0, 0), point(myTransitionMask.width, 0)], myTransitionMask.rect) end if end case end on endSprite me mySprite.member = myOriginalMember erase(myTransitionMember) end on prepareFrame me if (the frame >= myStartFrame) and (the frame <= myEndFrame) then elapsedFrames = the frame - myStartFrame + 1 memberRect = myTransitionMember.rect case direction of "left to right", "right to left": totalOffset = myTransitionMask.width - memberRect.width currentOffset = totalOffset * elapsedFrames / softWipeDuration if direction = "right to left" then currentMaskRect = offset(memberRect, currentOffset, 0) else currentMaskRect = offset(memberRect, totalOffset - currentOffset, 0) end if "top to bottom", "bottom to top": totalOffset = myTransitionMask.height - memberRect.height currentOffset = totalOffset * elapsedFrames / softWipeDuration if direction = "bottom to top" then currentMaskRect = offset(memberRect, 0, currentOffset) else currentMaskRect = offset(memberRect, 0, totalOffset - currentOffset) end if end case myAlphaMask.copyPixels(myOriginalAlpha, myOriginalAlpha.rect, myOriginalAlpha.rect) myAlphaMask.copyPixels(myTransitionMask, memberRect, currentMaskRect, [#ink: #lightest]) myTransitionMember.image.setAlpha(myAlphaMask) myTransitionMember.image.useAlpha = 1 mySprite.member = myTransitionMember else mySprite.member = myOriginalMember end if end on makeBlendRL me blendLine = image(256, 1, 8, 0, #grayscale) repeat with i = 0 to 255 blendLine.setPixel(i, 0, i) end repeat return blendLine end on makeBlendBoxRL me, boxWidth, boxHeight blendBox = image(boxWidth, boxHeight, 8, 0, #grayscale) blendBox.copyPixels(me.makeBlendRL(), blendBox.rect, rect(0, 0, 256, 1)) return blendBox end on makeBlendBoxLR me, boxWidth, boxHeight blendBox = image(boxWidth, boxHeight, 8, 0, #grayscale) blendBox.copyPixels(me.makeBlendBoxRL(boxWidth, boxHeight), [point(boxWidth, 0), point(0, 0), point(0, boxHeight), point(boxWidth, boxHeight)], rect(0, 0, boxWidth, boxHeight)) return blendBox end on makeSharpRL me sharpLine = image(2, 1, 8, 0, #grayscale) sharpLine.setPixel(0, 0, 0) sharpLine.setPixel(1, 0, 255) return sharpLine end on makeSharpBoxRL me, boxWidth, boxHeight sharpBox = image(boxWidth, boxHeight, 8, 0, #grayscale) sharpBox.copyPixels(me.makeSharpRL(), sharpBox.rect, rect(0, 0, 2, 1)) return sharpBox end on makeSharpBoxLR me, boxWidth, boxHeight sharpBox = image(boxWidth, boxHeight, 8, 0, #grayscale) sharpBox.copyPixels(me.makeSharpBoxRL(boxWidth, boxHeight), [point(boxWidth, 0), point(0, 0), point(0, boxHeight), point(boxWidth, boxHeight)], rect(0, 0, boxWidth, boxHeight)) return sharpBox end on makeSharpBoxTB me, boxWidth, boxHeight sharpBox = image(boxWidth, boxHeight, 8, 0, #grayscale) sharpBox.copyPixels(me.makeSharpRL(), [point(boxWidth, 0), point(boxWidth, boxHeight), point(0, boxHeight), point(0, 0)], rect(0, 0, 2, 1)) return sharpBox end on isOKToAttach me, aSpriteType, aSpriteNum isOK = 0 case aSpriteType of #graphic: case sprite(aSpriteNum).member.type of #bitmap, #flash, #vectorShape: isOK = 1 #text: if sprite(aSpriteNum).member.displayMode = #modeNormal then isOK = 1 end if end case end case return isOK end on getPropertyDescriptionList me props = [:] props[#appearWhen] = [#comment: "When transition appears:", #format: #string, #default: "beginning of sprite", #range: ["beginning of sprite", "end of sprite"]] firstFrame = sprite(the currentSpriteNum).startFrame endFrame = sprite(the currentSpriteNum).endFrame maxLength = endFrame - firstFrame + 1 props[#softWipeDuration] = [#comment: "Duration:", #format: #integer, #default: min(maxLength, 10), #range: [#min: 1, #max: maxLength]] props[#direction] = [#comment: "Direction:", #format: #string, #default: "left to right", #range: ["left to right", "right to left", "bottom to top", "top to bottom"]] minDim = min(sprite(the currentSpriteNum).member.width, sprite(the currentSpriteNum).member.height) props[#softWipeWidth] = [#comment: "Blend Width:", #format: #integer, #default: 15, #range: [#min: 2, #max: minDim]] return props end on getBehaviorTooltip return "Creates a transition where the sprite appears on or is removed from the stage with a blended edge wipe." end on getBehaviorDescription return "SOFT-EDGED WIPE TRANSITION" & RETURN & RETURN & "Drop this behavior onto a sprite to create an animation of the sprite sppearing on or disappearing from the stage with a blend ranging from completely transparent to fully opaque." & RETURN & RETURN & "Select when the transition will take effect: 'start' makes the sprite move onto the stage beginning at its first frame, 'end' moves it off at the end of its span. " & "The duration controls the number of frames over which the transition occurs. " & "Direction controls the movement of the sprite. " & "The width of the transition area from transparent to opaque is controlled by the setting for Blend width." & RETURN & RETURN & "When this transition is used during authoring, and the movie is stopped the cast member it uses for the transition effect may not be erased." & RETURN & RETURN & "PERMITTED MEMBER TYPES:" & RETURN & "bitmaps and text" & RETURN & RETURN & "PARAMETERS:" & RETURN & "* When transition appears - controls whether sprite moves on or off the stage" & RETURN & "* Duration - number of frames for the transition to take place" & RETURN & "* Direction - movement of sprite onto or off of the stage" & RETURN & "* Blend width - width of blend in pixels" end